import { defineStore } from 'pinia'
import { ref } from 'vue'

// 用户模块
export const useUserStore = defineStore(
  'big-user',
  () => {
    const token = ref('') // 定义 token
    const setToken = (newToken) => {
    token.value = newToken // 设置 token

  }

  const removeToken = () =>{
    token.value = ''
  }

  const userName =ref('') 
  const setUserName = (name) =>{
    userName.value = name
  }

    return {
       token, 
       setToken,
       removeToken,
       userName,
       setUserName
      }
  },
  {
    persist: true // 持久化
  }
)